/**
 * EditMusicServiceImp.java
 *
 *
 * $LastChangedBy: allen $
 * $LastChangedDate: 2007-11-26 11:29:11 +0800 $
 * $Revision: 1256 $
 */
package com.myspace.service.music;

import java.util.List;

import com.myspace.dao.MusicCommentDao;
import com.myspace.dao.MusicDao;
import com.myspace.dao.UserDao;
import com.myspace.domain.Music;
import com.myspace.domain.MusicComment;
import com.myspace.domain.User;
import com.myspace.common.exception.SystemException;

public class EditMusicServiceImp implements EditMusicService {

	private UserDao userDao;

	private MusicDao musicDao;

	MusicCommentDao musicCommentDao;

	public void addMusic(Long userId, Music music) {
		User user = userDao.findById(userId);
		if (user == null)
			throw new SystemException("User is not exists!");
		music.setUserId(userId);
		musicDao.save(music);
	}

	public void delMusic(Long id) {
		Music music = musicDao.findById(id);
		musicDao.delete(music);
	}

	public void updateMusic(Music music) {
		musicDao.update(music);
	}

	public Music getMusic(Long id) {
		return musicDao.findById(id);
	}

	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public MusicDao getMusicDao() {
		return musicDao;
	}

	public void setMusicDao(MusicDao musicDao) {
		this.musicDao = musicDao;
	}

	public MusicCommentDao getMusicCommentDao() {
		return musicCommentDao;
	}

	public void setMusicCommentDao(MusicCommentDao musicCommentDao) {
		this.musicCommentDao = musicCommentDao;
	}

	public List<MusicComment> getCommentList(Long musicId) {
		return musicCommentDao.findCommentsList(musicId);
	}

	public void saveMusicComment(MusicComment musicComment) {
		this.musicCommentDao.save(musicComment);
	}

}
